/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.unwiredgrain.modeling.sscm.impl;

import com.unwiredgrain.modeling.sscm.Binding;
import com.unwiredgrain.modeling.sscm.Socket;
import com.unwiredgrain.modeling.sscm.CompositeModule;
import com.unwiredgrain.modeling.sscm.OuterConnector;
import com.unwiredgrain.modeling.sscm.Connector;
import com.unwiredgrain.modeling.sscm.SSCMPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Composite Module</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.CompositeModuleImpl#getSockets <em>Sockets</em>}</li>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.CompositeModuleImpl#getOuterConnectors <em>Outer Connectors</em>}</li>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.CompositeModuleImpl#getBindings <em>Bindings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CompositeModuleImpl extends ModuleImpl implements CompositeModule {
	/**
	 * The cached value of the '{@link #getSockets() <em>Sockets</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSockets()
	 * @generated
	 * @ordered
	 */
	protected EList<Socket> sockets;

	/**
	 * The cached value of the '{@link #getOuterConnectors() <em>Outer Connectors</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOuterConnectors()
	 * @generated
	 * @ordered
	 */
	protected EList<OuterConnector> outerConnectors;

	/**
	 * The cached value of the '{@link #getBindings() <em>Bindings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBindings()
	 * @generated
	 * @ordered
	 */
	protected EList<Binding> bindings;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CompositeModuleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SSCMPackage.Literals.COMPOSITE_MODULE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Socket> getSockets() {
		if (sockets == null) {
			sockets = new EObjectContainmentEList<Socket>(Socket.class, this, SSCMPackage.COMPOSITE_MODULE__SOCKETS);
		}
		return sockets;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OuterConnector> getOuterConnectors() {
		if (outerConnectors == null) {
			outerConnectors = new EObjectContainmentEList<OuterConnector>(OuterConnector.class, this, SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS);
		}
		return outerConnectors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Binding> getBindings() {
		if (bindings == null) {
			bindings = new EObjectContainmentEList<Binding>(Binding.class, this, SSCMPackage.COMPOSITE_MODULE__BINDINGS);
		}
		return bindings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SSCMPackage.COMPOSITE_MODULE__SOCKETS:
				return ((InternalEList<?>)getSockets()).basicRemove(otherEnd, msgs);
			case SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS:
				return ((InternalEList<?>)getOuterConnectors()).basicRemove(otherEnd, msgs);
			case SSCMPackage.COMPOSITE_MODULE__BINDINGS:
				return ((InternalEList<?>)getBindings()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SSCMPackage.COMPOSITE_MODULE__SOCKETS:
				return getSockets();
			case SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS:
				return getOuterConnectors();
			case SSCMPackage.COMPOSITE_MODULE__BINDINGS:
				return getBindings();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SSCMPackage.COMPOSITE_MODULE__SOCKETS:
				getSockets().clear();
				getSockets().addAll((Collection<? extends Socket>)newValue);
				return;
			case SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS:
				getOuterConnectors().clear();
				getOuterConnectors().addAll((Collection<? extends OuterConnector>)newValue);
				return;
			case SSCMPackage.COMPOSITE_MODULE__BINDINGS:
				getBindings().clear();
				getBindings().addAll((Collection<? extends Binding>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SSCMPackage.COMPOSITE_MODULE__SOCKETS:
				getSockets().clear();
				return;
			case SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS:
				getOuterConnectors().clear();
				return;
			case SSCMPackage.COMPOSITE_MODULE__BINDINGS:
				getBindings().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SSCMPackage.COMPOSITE_MODULE__SOCKETS:
				return sockets != null && !sockets.isEmpty();
			case SSCMPackage.COMPOSITE_MODULE__OUTER_CONNECTORS:
				return outerConnectors != null && !outerConnectors.isEmpty();
			case SSCMPackage.COMPOSITE_MODULE__BINDINGS:
				return bindings != null && !bindings.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //CompositeModuleImpl
